package com.meilai.project.controller.web.business.media;

import com.meilai.project.dto.CommonResult;
import com.meilai.project.dto.business.media.MediaTypeSpecsDTO;
import com.meilai.project.service.media.MediaPointTypeSpecsRelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author ljy
 * @Date 2022/5/27 9:07
 */
@Api(value = "媒体类型控制器")
@RestController
@RequestMapping("api/web/media/type-specs-relation")
public class WebMediaPointTypeSpecsRelationController {
    @Autowired
    private MediaPointTypeSpecsRelationService service;

    @ResponseBody
    @PostMapping("edit")
    @ApiOperation("批量设置点位规格")
    public CommonResult save(@RequestBody @Valid MediaTypeSpecsDTO dto ) {
        try {
            if (service.editList(dto)) {
                return new CommonResult().success("设置成功");
            } else {
                return new CommonResult().failed("设置失败");
            }
        } catch (Exception e) {
            return new CommonResult().failed(e.getMessage());
        }
    }
}
